package com.bw.finance.controller;


import com.bw.finance.conf.ResponseResult;
import com.bw.finance.eneity.invest.BiaoInfo;
import com.bw.finance.eneity.locana.EbankBidInfo;
import com.bw.finance.eneity.user.EbankBorrower;
import com.bw.finance.mapper.EbankBidInfoMapper;
import com.bw.finance.service.IEbankBidInfoService;
import com.bw.finance.service.IEbankLoanInfoService;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zxx
 * @since 2020-08-19
 */
@RestController
@RequestMapping("/ebankbidinfo")
public class EbankBidInfoController {
    @Resource
    private IEbankBidInfoService iEbankBidInfoService;
    @Resource
    private IEbankLoanInfoService iEbankLoanInfoService;

    @Autowired
    private EbankBidInfoMapper bidInfoMapper;

    //添加标的数据
    @PostMapping("/toadd")
    public ResponseResult findone(@RequestBody EbankBidInfo ebankBidInfo){
        return iEbankBidInfoService.toadd(ebankBidInfo);
    }
    //招标管理列表
    @PostMapping("/biaocheckmg/{pagenum}/{pagesize}")
    public ResponseResult biaocheckmg(@PathVariable int pagenum , @PathVariable int pagesize, @RequestBody EbankBidInfo bidInfo){
        return iEbankBidInfoService.biaocheckmg(pagenum,pagesize,bidInfo);
    }
    //招标管理列表
    @PostMapping("/updateStatus01/{id}/{val}")
    public ResponseResult updateStatus01(@PathVariable int id , @PathVariable int val ){
        return iEbankBidInfoService.updateStatus01(id,val);
    }


    @PostMapping("getebankList/{pagenum}/{pagesize}")
    public ResponseResult getebankList(@PathVariable int pagenum , @PathVariable int pagesize, @RequestBody EbankBidInfo bidInfo){
        return iEbankBidInfoService.getebankList(pagenum,pagesize,bidInfo);
    }

    @PostMapping("updateStatus/{id}/{status}")
    public ResponseResult updateStatus(@PathVariable long id , @PathVariable int status){
        return iEbankBidInfoService.updateStatus(id,status);
    }

    @PostMapping("getListAll/{pagenum}/{pagesize}")
    public ResponseResult getListAll(@PathVariable int pagenum , @PathVariable int pagesize, @RequestBody EbankBorrower borrower){
        return iEbankBidInfoService.getListAll(pagenum,pagesize,borrower);
    }

    /*//查看借款信息
    @PostMapping("getborrowall/{pagenum}/{pagesize}")
    public ResponseResult getborrowall(@PathVariable int pagenum , @PathVariable int pagesize, @RequestBody EbankBorrower borrower){
        return iEbankLoanInfoService.getborrowall(pagenum,pagesize,borrower);
    }*/

    @PostMapping("/toLookById/{id}")
    public ResponseResult toLookById(@PathVariable("id") Long id){
        return iEbankBidInfoService.toLookById(id);
    }

    @PostMapping("/updateDetail")
    public ResponseResult toLookById(@RequestBody EbankBidInfo bidInfo){
        return iEbankBidInfoService.updateDetail(bidInfo);
    }

    @PostMapping("/DeleteById/{id}")
    public ResponseResult DeleteById(@PathVariable("id") Long id){
        ResponseResult result = ResponseResult.SUCCESS();
        try {
            iEbankBidInfoService.removeById(id);
            result.setMessage("删除成功!");
            result.setSuccess(true);
        }catch (Exception e){
            result.setSuccess(false);
            result.setMessage("删除异常");
            e.printStackTrace();
        }
        return result;
    }

    @PostMapping("/getone")
    private BiaoInfo getone(@RequestParam Long id){
        return bidInfoMapper.selectone(id);
    }

}
